from likeshop_api_project.api.login_api import login_model
from likeshop_api_project.base.mybase import Tools


# 添加收货地址
class add_address_model(Tools):
    path = '/api/user_address/add'

    def add_address_action(self, contact, telephone, province_id, city_id, district_id, address, is_default, hd):
        add_address_data = {
            "contact": contact,
            "telephone": telephone,
            "province_id": province_id,
            "city_id": city_id,
            "district_id": district_id,
            "address": address,
            "is_default": is_default
        }
        add_address = self.huihua.post(url=self.hosturl+self.path, data=add_address_data, headers=hd)
        return add_address.json()


if __name__ == '__main__':
    import requests

    s = requests.session()
    reg = login_model(huihua=s)
    msg = reg.login_action(account="13356786546", password="rr98765", client=2)
    # print(msg)
    get_token = msg["data"]["token"]
    # print(get_token)
    hd = {"token": get_token}

    add_address = add_address_model(huihua=s)
    msg = add_address.add_address_action(contact="玛卡巴卡", telephone=13398763456, province_id=110000, city_id=110100,
                                         district_id=110101, address='武汉市江夏区藏龙岛', is_default=1, hd=hd)
    print(msg)
